home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 70 / IOPROG_70.ISO / soft / Codice / Libro Allegato / UserForm1.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2003-05-02  |  1.5 KB  |  50 lines

  1. VERSION 5.00
  2. Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} UserForm1 
  3.    Caption         =   "Mostra valori foglio corrente"
  4.    ClientHeight    =   3225
  5.    ClientLeft      =   45
  6.    ClientTop       =   330
  7.    ClientWidth     =   4710
  8.    OleObjectBlob   =   "UserForm1.frx":0000
  9.    StartUpPosition =   1  'CenterOwner
  10. Attribute VB_Name = "UserForm1"
  11. Attribute VB_GlobalNameSpace = False
  12. Attribute VB_Creatable = False
  13. Attribute VB_PredeclaredId = True
  14. Attribute VB_Exposed = False
  15. Option Explicit
  16. Private Sub CommandButton1_Click()
  17.     Dim str As String
  18.     str = Application.GetOpenFilename()
  19.     If (str <> "Falso" And str <> "False") Then MostraCelle str
  20. End Sub
  21. Private Sub TextBox1_AfterUpdate()
  22.     Call MostraCelle(TextBox1.Text)
  23. End Sub
  24. Private Sub UserForm_Initialize()
  25.     Call MostraCelle(TextBox1.Text)
  26. End Sub
  27. Private Sub MostraCelle(filePath As String)
  28.     Dim sheet As Excel.Worksheet
  29.     Dim rng As Excel.Range
  30.     Dim cella As Variant
  31.     Dim ch As String
  32.     On Error GoTo Errore
  33.     If (filePath > "") Then
  34.         Set sheet = Application.Workbooks.Open(filePath).Worksheets(1)
  35.         sheet.Activate
  36.     End If
  37.     ListBox1.Clear
  38.     Set sheet = Application.ActiveSheet
  39.     Set rng = sheet.Cells.CurrentRegion
  40.     For Each cella In rng
  41.         If (cella.Text > "") Then ListBox1.AddItem cella.Text
  42.     Next
  43.     GoTo Fine
  44. Errore:
  45.     MsgBox "Si 
  46.  verificato un errore aprendo il file:" & vbCrLf & _
  47.         Err.Description
  48. Fine:
  49. End Sub
  50.